(C) 1996 AROS - The Amiga Replacement OS


NAME
#include <dos/datetime.h>
#include <proto/dos.h>
BOOL DateToStr()
SYNOPSIS
struct DateTime * datetime

LOCATION
In DOSBase at offset 124
FUNCTION
DateToStr converts an AmigaDOS DateStamp to a human readable ASCII string as requested by your settings in the DateTime structure.

INPUTS
DateTime
a pointer to an initialized DateTime structure. The DateTime structure should be initialized as follows: \begin{description} \item{dat_Stamp} The datestamp to convert to ascii \item{dat_Format} How to convert the datestamp into dat_StrDate. Can be any of the following: \begin{description}
dd
mmm-yy). This is the default if you specify something other than any entry in this list.
yy
mmm-dd).
mm
dd-yy).
dd
mm-yy). \item{FORMAT_DEF} default format for locale. \end{description} \item{dat_Flags} Modifies dat_Format. The only flag used by this function is DTF_SUBST. If set, then a string like "Today" or "Monday" is generated instead of the normal format if possible. \item{dat_StrDay} Pointer to a buffer to receive the day of the week string. (Monday, Tuesday, etc.). If null, this string will not be generated. \item{dat_StrDate} Pointer to a buffer to receive the date string, in the format requested by dat_Format, subject to possible modifications by DTF_SUBST. If null, this string will not be generated. \item{dat_StrTime} Pointer to a buffer to receive the time of day string. If NULL, this will not be generated. \end{description}
RESULT
A zero return indicates that the DateStamp was invalid, and could not be converted. Non-zero indicates that the call succeeded.

NOTES
EXAMPLE
#include 
#include 
#undef AROS_LH1
#undef DateToStr
#undef AROS_LHA
#define AROS_LH1(ret,name,arg,type,base,offset,libname) \
    ret name (arg)
#define AROS_LHA(type,name,reg) type name

#include 
#include 
#include 

int main (int argc, char ** argv)
{
    struct DateTime curr;
    char day[LEN_DATSTRING];
    char time[LEN_DATSTRING];
    char date[LEN_DATSTRING];

    DateStamp (&curr.dat_Stamp);

    curr.dat_Format  = FORMAT_DOS;
    curr.dat_Flags   = 0;
    curr.dat_StrDay  = day;
    curr.dat_StrDate = date;
    curr.dat_StrTime = time;

    DateToStr (&curr);

    printf ("Today is %s, %s. It's %s\n"
	, day
	, date
	, time
    );

    curr.dat_Format = FORMAT_DEF;

    DateToStr (&curr);

    printf ("Local date: %s\n", date);

    curr.dat_Flags = DTF_SUBST;

    DateToStr (&curr);

    printf ("Date with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days ++;

    DateToStr (&curr);

    printf ("Date +1 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days ++;

    DateToStr (&curr);

    printf ("Date +2 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days ++;

    DateToStr (&curr);

    printf ("Date +3 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days -= 4;

    DateToStr (&curr);

    printf ("Date -1 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days --;

    DateToStr (&curr);

    printf ("Date -2 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days --;

    DateToStr (&curr);

    printf ("Date -3 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days   = 0;
    curr.dat_Stamp.ds_Minute = 0;
    curr.dat_Stamp.ds_Tick   = 0;

    DateToStr (&curr);

    printf ("First Date: %s, %s. Time: %s\n", day, date, time);

    curr.dat_Stamp.ds_Days   = 0;
    curr.dat_Stamp.ds_Minute = 1;
    curr.dat_Stamp.ds_Tick   = 0;

    DateToStr (&curr);

    printf ("First Date + 1 Minute: %s, %s. Time: %s\n", day, date, time);

    curr.dat_Stamp.ds_Days   = 0;
    curr.dat_Stamp.ds_Minute = 0;
    curr.dat_Stamp.ds_Tick   = 153;

    DateToStr (&curr);

    printf ("First Date + 153 Ticks: %s, %s. Time: %s\n", day, date, time);

    curr.dat_Stamp.ds_Days   = 1;
    curr.dat_Stamp.ds_Minute = 0;
    curr.dat_Stamp.ds_Tick   = 0;

    DateToStr (&curr);

    printf ("First Date: %s, %s. Time: %s\n", day, date, time);

    return 0;
} /* main */

BUGS
SEE ALSO
DateStamp(), StrtoDate()
INTERNALS
HISTORY
18.02.1997 digulla
Polish

Added test code

Added docs

Added missing functionality

AROS uses 4 chars for the date (ie. 2001) but does also accept 97 for 1997.

27.01.1997 ldp
Polish
09.12.1996 aros
Added empty templates for all missing functions

Moved #include's into first column

21.11.1996 aros
Created macros AROS_SLIB_ENTRY() for assembler files, too, to solve naming problems.

The #includes in the header *must* begin in the first column. Otherwise makedepend will ignore them (GCC works, though).

Removed a couple of Logs

24.10.1996 aros
Use the official AROS macros over the __AROS versions.
13.08.1996 digulla
Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h" Replaced __AROS_LA by __AROS_LHA
01.08.1996 digulla
Added standard header for all files
28.07.1996 digulla
Initial revision
28.07.1996 digulla
First CVS version of AROS